import logging

from config import BASE_HOST


class RechargeApi:

    def __init__(self, session):
        self.session = session

    # 接收session对象的变量

    # 获取充值验证码接口
    def get_recharge_verify_code(self, r):
        url = BASE_HOST + f'/common/public/verifycode/{r}'
        resp = self.session.get(url=url)
        logging.info(f'获取充值验证码状态码:{resp.status_code}')
        return resp

    # 充值接口
    def recharge(self, body):
        # 定义一个字典变量，用来接收请求体数据
        url = BASE_HOST + '/trust/trust/recharge'
        resp = self.session.post(url=url, data=body)
        logging.info(f'充值: {resp.json()}')
        return resp

    # 第三方充值接口
    def third_recharge(self, url, body):
        resp = self.session.post(url=url, data=body)
        logging.info(f'第三方充值: {resp.text}')
        return resp
